package com.snu.liwei.lyl_api.controller;

import com.snu.liwei.lyl_api.request.UploadLimitingReq;
import com.snu.liwei.lyl_api.response.LimitingPageRep;
import com.snu.liwei.lyl_api.service.LitimgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 缩略图控制器
 */
@Api("缩略图控制器")
@Slf4j
@RestController
@CrossOrigin(origins = {"http://192.168.31.215:3000", "http://127.0.0.1:3000"})
public class LimitImageController {

    @Autowired
    private LitimgService litimgService;



    // 保存缩略图片
    @ApiOperation("保存缩略图片")
    @RequestMapping(value = "/saveLimiting.do", method = RequestMethod.POST)
    public void saveLimiting(
            @RequestBody UploadLimitingReq uploadLimitingReq) throws Exception {
        litimgService.save(uploadLimitingReq);
    }


    @ApiOperation("分页查询缩略图")
    @GetMapping("getLimitingByPage")
    public LimitingPageRep getLimitingByPage(
            @RequestParam("page") Integer page,
            @RequestParam("size") Integer size,
            @RequestParam(value = "gid",required = false) String gid) throws Exception {
        return litimgService.getLimitingByPage(page, size, gid);
    }

}
